﻿/*----------------------------------------------------------------
// Copyright (C) 2012
// 版权所有
//
// 文件名：OrderOnline_Model.cs
// 文件功能描述：
//
//
// 创建标识：Libing 2012-05-07 21:10:34 星期一
//
// 修改标识：
// 修改描述：
//----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.Text;

namespace WMS.BLL
{
    public class OrderOnline_Model
    {
        private static readonly WMS.IDAL.IOrderOnline_Model dal = WMS.DALFactory.OrderOnline_Model.Create();

        #region 基本方法

        /// <summary>
        /// 创建实体(可实现添加、修改操作)
        /// </summary>
        /// <param name="model">类型为WMS.Model.OrderOnline_Model的实体对象</param>
        /// <returns></returns>
        public bool Create(WMS.Model.OrderOnline_Model orderOnlineModel)
        {
            switch (orderOnlineModel.ModelState)
            {
                case WMS.Model.Enum.ModelState.Insert:
                    return Insert(orderOnlineModel);

                case WMS.Model.Enum.ModelState.Update:
                    return Update(orderOnlineModel);

                case WMS.Model.Enum.ModelState.UpdateMinimal:
                    return UpdateMinimal(orderOnlineModel);

                default:
                    return false;
            }
        }

        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="model">类型为WMS.Model.OrderOnline_Model的实体对象</param>
        /// <returns></returns>
        public bool Insert(WMS.Model.OrderOnline_Model orderOnlineModel)
        {
            try
            {
                return dal.Insert(orderOnlineModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="model">类型为WMS.Model.OrderOnline_Model的实体对象</param>
        /// <returns></returns>
        public bool Update(WMS.Model.OrderOnline_Model orderOnlineModel)
        {
            try
            {
                return dal.Update(orderOnlineModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="model">类型为WMS.Model.OrderOnline_Model的实体对象</param>
        /// <returns></returns>
        public bool UpdateMinimal(WMS.Model.OrderOnline_Model orderOnlineModel)
        {
            try
            {
                return dal.UpdateMinimal(orderOnlineModel);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 删除实体(根据主键 ID)
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns></returns>
        public bool DeleteByID(string id)
        {
            try
            {
                return dal.DeleteByID(id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 删除实体(指定条件)
        /// </summary>
        /// <param name="whereClause">WHERE语句</param>
        /// <returns></returns>
        public bool DeleteDynamic(string whereClause)
        {
            try
            {
                return dal.DeleteDynamic(whereClause);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 获取实体(根据主键 ID)
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns></returns>
        public WMS.Model.OrderOnline_Model GetByID(string id)
        {
            try
            {
                return dal.GetByID(id);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        #endregion

        #region	公共方法

        /// <summary>
        /// 获取实体列表(指定数目和查询条件)
        /// </summary>
        /// <param name="topClause">指定实体数</param>
        /// <param name="whereClause">WHERE语句</param>
        /// <returns></returns>
        public List<WMS.Model.OrderOnline_Model> Get(int topClause, string whereClause)
        {
            try
            {
                return dal.Get(topClause, whereClause);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 获取实体列表(指定查询条件)
        /// </summary>
        /// <param name="whereClause">WHERE语句</param>
        /// <returns></returns>
        public List<WMS.Model.OrderOnline_Model> Get(string whereClause)
        {
            try
            {
                return dal.Get(whereClause);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 获取分页实体列表
        /// </summary>
        /// <param name="whereClause">WHERE 语句</param>
        /// <param name="orderByClause">ORDER BY 语句</param>
        /// <param name="pageIndex">分页索引</param>
        /// <param name="pageSize">分页大小(每页显示的记录数)</param>
        /// <param name="totalRecords">记录总数</param>
        /// <returns></returns>
        public List<WMS.Model.OrderOnline_Model> GetPaged(string whereClause, string orderBy, int pageIndex, int pageSize, out int totalRecords)
        {
            try
            {
                return dal.GetPaged(whereClause, orderBy, pageIndex, pageSize, out totalRecords);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        #endregion

        #region 自定义方法

        /// <summary>
        /// 获取全部实体列表
        /// </summary>
        /// <returns></returns>
        public List<WMS.Model.OrderOnline_Model> GetAll()
        {
            try
            {
                return dal.GetAll();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        /// <summary>
        /// 根据角色权限获取一级菜单
        /// </summary>
        /// <param name="rolePermission">角色权限</param>
        /// <returns></returns>
        public List<WMS.Model.OrderOnline_Model> GetByPermission(string rolePermission)
        {
            try
            {
                return dal.GetByPermission(rolePermission);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex);
            }
        }

        #endregion
    }
}